package org.jeecg.modules.hc.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum HcWalletSourceEnum {
    SHARE("share", "分享"),
    AFTER_SALES("after_sales", "售后"),
    PAY("pay", "付款"),
    REFUND("refund", "退款"),
    ;

    @EnumValue
    private final String value;
    @JsonValue
    private final String name;

    HcWalletSourceEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public static HcWalletSourceEnum get(String val) {
        Optional<HcWalletSourceEnum> first = Arrays.stream(HcWalletSourceEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        return first.orElse(null);
    }

    public static HcWalletSourceEnum getByName(String name) {
        Optional<HcWalletSourceEnum> first = Arrays.stream(HcWalletSourceEnum.values()).filter(e -> e.getName().equals(name)).findFirst();
        return first.orElse(null);
    }
}
